//---------------------------------------------------------------------------
//
// Name:        Tic.cpp
// Author:      Retral
// Created:     6/7/2007 2:47:33 PM
// Description: Tic class implementation
//
//---------------------------------------------------------------------------

#include "Tic.h"
#include "Tac.h"

//Do not add custom headers between
//Header Include Start and Header Include End
//wxDev-C++ designer will remove them
////Header Include Start
////Header Include End

//----------------------------------------------------------------------------
// Tic
//----------------------------------------------------------------------------
//Add Custom Events only in the appropriate block.
//Code added in other places will be removed by wxDev-C++
////Event Table Start
BEGIN_EVENT_TABLE(Tic,wxFrame)
	////Manual Code Start
	////Manual Code End
	
	EVT_CLOSE(Tic::OnClose)
	EVT_BUTTON(ID_WXBUTTON2,Tic::WxButton2Click)
	EVT_BUTTON(ID_WXBUTTON1,Tic::WxButton1Click)
END_EVENT_TABLE()
////Event Table End

Tic::Tic(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style)
{
	CreateGUIControls();
}

Tic::~Tic()
{
}

void Tic::CreateGUIControls()
{
	//Do not add custom code between
	//GUI Items Creation Start and GUI Items Creation End
	//wxDev-C++ designer will remove them.
	//Add the custom code before or after the blocks
	////GUI Items Creation Start

	SetTitle(wxT("Tic"));
	SetIcon(wxNullIcon);
	SetSize(8,8,290,114);
	Center();
	

	WxButton2 = new wxButton(this, ID_WXBUTTON2, wxT("Cancel"), wxPoint(154,41), wxSize(88,37), 0, wxDefaultValidator, wxT("WxButton2"));
	WxButton2->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));

	WxEdit1 = new wxTextCtrl(this, ID_WXEDIT1, wxT(""), wxPoint(133,6), wxSize(133,23), 0, wxDefaultValidator, wxT("WxEdit1"));
	WxEdit1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));

	WxStaticText1 = new wxStaticText(this, ID_WXSTATICTEXT1, wxT("Please enter your name:"), wxPoint(10,11), wxDefaultSize, 0, wxT("WxStaticText1"));
	WxStaticText1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));

	WxButton1 = new wxButton(this, ID_WXBUTTON1, wxT("OK"), wxPoint(46,41), wxSize(88,37), 0, wxDefaultValidator, wxT("WxButton1"));
	WxButton1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
	////GUI Items Creation End
}

void Tic::OnClose(wxCloseEvent& event)
{
	Destroy();
}

/*
 * WxButton1Click
 */
void Tic::WxButton1Click(wxCommandEvent& event)
{
	Tac* frame = new Tac(NULL);
    frame->Show();
    WxButton1->SetLabel(WxEdit1->GetValue());
    //Destroy();
    
    /*
    int sockfd;
	struct sockaddr_in serv_addr;

    sockfd = socket(PF_INET, SOCK_STREAM, 0);

	memset(&serv_addr, 0, sizeof(serv_addr));
	serv_addr.sin_family = AF_INET;
	serv_addr.sin_port = htons(PORT);
	serv_addr.sin_addr.s_addr = inet_addr(IP);

	connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr);
	*/
}

/*
 * WxButton2Click
 */
void Tic::WxButton2Click(wxCommandEvent& event)
{
    Destroy();
}
